package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.entity.BiddEntity;
import com.project.entity.ConfirmGoodsEntity;
import com.project.entity.ConfirmOrderEntity;
import com.project.mapper.IBiddMapper;
import com.project.mapper.IConfirmGoodsMapper;
import com.project.mapper.IConfirmOrderMapper;
import com.project.service.IBiddService;
import com.project.service.IConfirmOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ConfirmOrderServiceImpl implements IConfirmOrderService {

    @Autowired
    private IConfirmOrderMapper confirmOrderMapper;

    @Autowired
    private IConfirmGoodsMapper confirmGoodsMapper;
    /**
     *查找中标确认表
     */
    @Override
    public IPage<ConfirmOrderEntity> findByItem(int pageNO, int pageSize, int confirm) {
        QueryWrapper<ConfirmOrderEntity> qw = new QueryWrapper<>();
        qw.eq("b_confirm",confirm);
        return confirmOrderMapper.selectPage(new Page<>(pageNO,pageSize),qw);
    }



    @Override
    public ConfirmOrderEntity findById(Integer confirmRef) {
        QueryWrapper<ConfirmOrderEntity> qw = new QueryWrapper<>();
        qw.eq("pk_confirmRef",confirmRef);
        ConfirmOrderEntity confirmOrderEntity = confirmOrderMapper.selectOne(qw);

        QueryWrapper<ConfirmGoodsEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("fk_confirmRef",confirmRef);
        List<ConfirmGoodsEntity> confirmGoodsEntityList = confirmGoodsMapper.selectList(queryWrapper);

        confirmOrderEntity.setConfirmGoodsEntityList(confirmGoodsEntityList);

        return confirmOrderEntity;
    }


}
